//
//  PKRootLeftViewController.m
//  Awhile
//
//  Created by lanou on 15/9/25.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKRootLeftViewController.h"
#import "PKRootRithtViewController.h"
#import "PKPlayerManger.h"
#import "UIImageView+WebCache.h"
@interface PKRootLeftViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic, strong)PKRootRithtViewController *rootRightVC;
@property(nonatomic, strong)UITableView *mainListTableView; // 主列表
@property(nonatomic, strong)NSArray *dataSourceArray;// 提供数据源
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *descLabel;
@property(nonatomic, strong)UIImageView *musicimg;
@end

@implementation PKRootLeftViewController


-(NSArray *)dataSourceArray
{
    if (!_dataSourceArray) {
        _dataSourceArray = @[@"有声书",@"音乐",@"儿童"];
    }
    return _dataSourceArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 添加右侧视图控制器到左侧视图控制器
    UIImageView *backImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
    [backImageView setImage:[UIImage imageNamed:@"defaultCover"]];
    _mainListTableView.backgroundView = backImageView;
    
    
    _mainListTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 70, [UIScreen mainScreen].bounds.size.width - 40, [UIScreen mainScreen].bounds.size.height - 20)];
    _mainListTableView.dataSource = self;
    _mainListTableView.delegate = self;
    [_mainListTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"mainListTableView"];
    _mainListTableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
//    _mainListTableView.scrollEnabled = YES;
    NSLog(@"%f",_mainListTableView.bounds.size.height);
    [self.view addSubview:_mainListTableView];
    
    
    
    UIView *radioView = [[UIView alloc]initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height-80, [UIScreen mainScreen].bounds.size.width, 80)];
    radioView.backgroundColor = [UIColor colorWithRed:0.127 green:0.157 blue:0.054 alpha:1.000];
    [self.view addSubview:radioView];
    
    _musicimg = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 50, 50)];
    _musicimg.backgroundColor = [UIColor whiteColor];
    [_musicimg setImage:[UIImage imageNamed:@"iconfont-v24bofangpress"]];
    [radioView addSubview:_musicimg];
    
    _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 20, 180, 20)];
    _descLabel.font = [UIFont systemFontOfSize:12];
    _titleLabel.textColor = [UIColor whiteColor];
    [radioView addSubview:_titleLabel];
    
    _descLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, 45, 180, 15)];
    _descLabel.textColor = [UIColor whiteColor];
    _descLabel.font = [UIFont systemFontOfSize:10];
    [radioView addSubview:_descLabel];
    
    
    _rootRightVC = [[PKRootRithtViewController alloc]init];
    [self.view addSubview:_rootRightVC.view];
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSourceArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mainListTableView" forIndexPath:indexPath];
    
    cell.textLabel.text = self.dataSourceArray[indexPath.row];
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_rootRightVC changeViewIndex:indexPath.row];
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}







/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
